package com.bailiban.aigou.admin.dao.impl;


import java.util.List;

import javax.annotation.Resource;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.bailiban.aigou.admin.dao.AigouBackstageDao;
import com.bailiban.aigou.admin.entity.BackstageUser;

@Repository
public class AigouBackstageDaoImpl implements AigouBackstageDao  {
	@Resource
	private SessionFactory sessionFactory;

	public BackstageUser getUserByUsername(String username) {
	
		Session session = sessionFactory.getCurrentSession();
		Query query = session.createQuery("from BackstageUser where username=:name");
		query.setParameter("name", username);
		
		List<BackstageUser> list = query.list();
		if (list==null || list.size()<=0) {
			return null;
		}
		return list.get(0);
		
	}

	

}
